home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 4⁄6⁄90 / 0095-Who's on first?-Apr90 < prev    next >
Encoding:
Text File  |  1990-04-06  |  1.4 KB  |  42 lines  |  [TEXT/GEOL]

  1. Item    9856462                         4-April-90        00:39PDT
  2.  
  3. From:   D0532                           Aidea Systems, Don Park,PRT
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  7.  
  8. Sub:    Who's on first?
  9.  
  10. Does anyone know what the order of static object instantiation is?
  11.  
  12. Here is the situation:
  13.  
  14. in file A.cp:
  15.  
  16.     static class AClass { ... } A;
  17.  
  18. in file B.cp:
  19.  
  20.     static class BClass { ... } B;
  21.  
  22. Now suppose BClass constructor calls AClass.  It would be a disaster if A is
  23. not instantiated before B.  I understand that the situation would be clear if
  24. both static objects were in one file, but how does one specify the order of
  25. instantiation among static objects scattered across files?
  26.  
  27. If the linker figures this out by noting that B uses A so A has to be
  28. instantiated first, then is that the standard or specific to MPW?
  29.  
  30. If the order of linking determines the order of instantiation, then it seem a
  31. bit limiting since file A.cp and B.cp could have another pair of static objects
  32. with reverse relationship.
  33.  
  34. If there is no guarantee of order, then I will have to require static objects
  35. that access other static objects to delay access until one can be sure that all
  36. static objects have been instantiated.  This is clearly a hack.
  37.  
  38. So, who is on first?
  39.  
  40. Don Park
  41.  
  42.